﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 小次郎点餐系统
{
    public partial class zhuceForm : Form
    {
        public zhuceForm()
        {
            InitializeComponent();
        }
        private void zhuceForm_Load(object sender, EventArgs e)
        {
            lable_phone.Visible = false;
        }
        private void btn_zhuce_Click(object sender, EventArgs e)
        {
            string pwd1 = this.txt_zhuce_pwd.Text.Trim();
            string pwd = this.txt_zhuce_pwd2.Text.Trim();
            if (pwd!=pwd1)
            {
                MessageBox.Show("确认密码与之前密码不符合，请重新输入！");
                return;
            }
            if (txt_phone.Text.Length>11)
            {
                this.lable_phone.Visible = true;
                return;
            }
            foreach (var item in this.Controls)
            {
                if (item is TextBox)
                {
                    TextBox txt = item as TextBox;
                    if (txt.Text=="")
                    {
                        MessageBox.Show("控件内容不能为空！");
                        return;
                    }
                }
            }
            string account = this.txt_zhuce_name.Text.Trim();
            string phone = this.txt_phone.Text.Trim();
            string sql = string.Format("insert [user](account,password,phone) values('{0}','{1}','{2}')", account, pwd, phone);
            int rs = DBHelper.write(sql);
            if (rs > 0)
            {
                MessageBox.Show("注册成功，祝您使用愉快");
            }
            else
            {
                MessageBox.Show("注册失败...");
            }
        }
    }
}
